﻿@model projectManagementWeb.Models.ProjectLeader.deleteModuleModel

@{
    ViewBag.Title = "Eliminar Modulo";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div align="right">
    @Html.ActionLink("<< Regresar", "ModuleIndex")
</div>


<style type="text/css">
.ui-datepicker { width: 17em; padding: .2em .2em 0; background: #66FF99;}
</style>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".date").datepicker
            ({
                dateFormat: 'mm/dd/yy',
                showStatus: true,
                showWeeks: true,
                highlightWeek: true,
                numberOfMonths: 1,
                showAnim: "scale",
                showOptions: {
                    origin: ["top", "left"]
                }
            });
    });
</script>

<script type="text/javascript">
function updateProjectsID() {
        var idProject = $("#ddlProject").val();
        $.getJSON("/ProjectLeader/loadModulesByProjectID", { id: idProject },
					function (moduleData) {
					    var select = $("#ID");
					    select.empty();
					    select.append($('<option/>', {
					        value: 0,
					        text: "Seleccione un Módulo"
					    }))
					    $.each(moduleData,
							function (index, itemData) {
							    if (itemData.Text != "Ninguno") {
							        select.append($('<option/>', { value: itemData.Value, text: itemData.Text }));
							    }
							});

					}
				);
			$("#ID").val(0);
					updateModel();
};
function updateModel() {
    $("#Name").val("");
    $("#Description").val("");
    $("#startDate").val("");
    $("#endDate").val("");
    var idModule = $("#ID").val();
    $.getJSON("/ProjectLeader/loadModuleInfo", { id: idModule },
					function (moduleData) {
					    

					    $("#Name").text(moduleData.name);
					    $("#Description").text(moduleData.description);
					    $("#startDate").text(moduleData.startDate);
					    $("#endDate").text(moduleData.endDate);
                        
					}
				);
}

    $(document).ready(

	function () {
	    updateProjectsID();
	    updateModel();
	    $("#ddlProject").change(    function(){updateProjectsID();}   );
	    $("#ID").change(     function() { updateModel(); }   );
	}
);

</script>


@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Eliminar Módulo</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.projectID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.projectID, new SelectList(Model.ProjectIDList, "Value", "Text", Model.projectID), null, new { id = "ddlProject" }) 
            @Html.ValidationMessageFor(model => model.projectID)
        </div>

         <div class="editor-field">
        @Html.DropDownListFor(model => model.ID, new SelectList(Enumerable.Empty<SelectListItem>(), "id", "ModelName"), 
            null, new { id = "ID" })
            @Html.ValidationMessageFor(model => model.ID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            <div id="Name"></div>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            <div id="Description"></div>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.startDate)
        </div>
        <div class="editor-field">
            <div id="startDate"></div>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.endDate)
        </div>
        <div class="editor-field">
            <div id="endDate"></div>
        </div>

        
        <div style="color:red;">
            Precaucion! Si elimina un módulo todas sus tareas también serán eliminadas
        </div>

        <p>
            <input type="submit" value="Eliminar" />
        </p>
    </fieldset>
}


